<?php


namespace app\cms\admin\controller\merchant;

use app\cms\model\merchant\merchantModel;
use iflow\auth\Authorize\AuthAnnotation;
use iflow\Response;
use iflow\Router\Controller;
use iflow\Router\implement\Request\{ GetMapping, PostMapping };

#[Controller('%cmsAdmin%/merchManagement')]
class merchantManagement
{
    /**
     * 获取商户列表
     * @param string $merchant_name
     * @param int $merchant_type
     * @param int $status
     * @return Response
     * @throws \think\db\exception\DbException
     */
    #[GetMapping]
    #[AuthAnnotation('merchManagement', 'merchManagementReadWrite|merchManagementRead')]
    public function get(string $merchant_name, int $merchant_type, int $status): Response
    {
        return (new merchantModel()) -> getMerchantList(
            $merchant_name,
            $merchant_type,
            $status
        );
    }

    /**
     * 解/封禁商户
     * @param int $merchant_id
     * @param int $status
     * @return Response
     */
    #[PostMapping]
    #[AuthAnnotation('merchManagement', 'merchManagementReadWrite|merchManagementWrite')]
    public function banOrUnblockMerch(int $merchant_id, int $status): Response
    {
        return (new merchantModel()) -> banOrUnblockMerch($merchant_id, $status);
    }
}